package com.oasystem.utils;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class DateUtils {
	
	public static String getYesterdayDateString() {
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.DATE, -1);
		return new SimpleDateFormat("yyyy-MM-dd ").format(cal
				.getTime());
	}
	
	public static String getTodayDateString() {
		Calendar cal = Calendar.getInstance();
		return new SimpleDateFormat("yyyy-MM-dd ").format(cal
				.getTime());
	}
	
	public static String getCurrentTimeString() {
		Calendar cal = Calendar.getInstance();
		return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal
				.getTime());
	}
	
	public static String format(String patten, Timestamp time) {
		if(time==null) return null;
		return new SimpleDateFormat(patten).format(time);
	}
	
	public static void main(String[] args) {
		System.out.println(DateUtils.getCurrentTimeString());
	}
}
